import { rolelist } from "@/request/api";

// 封装接口类型  state遵循这个规则 必须有roleList这个参数
interface  StateRole{
    roleList:Array<Object>
}

const state = {
    roleList:[]
}

const mutations = {
    ROLE_LIST(state:StateRole,payload:any){
        state.roleList = payload
    }
}

const actions = {
    getRoleListActions(context:any){
        rolelist().then((res:any)=>{
            if(res.code==200){
                context.commit('ROLE_LIST',res.list);
            }
        })
    }
}

const getters = {
    getRoleList(state:StateRole){
        return state.roleList
    }
}

export default {
    state,
    mutations,
    actions,
    getters,
    namespaced:true
}